@ampless/admin 0.2.0-alpha.1 → 0.2.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from 'next/server';
2
2
  import { Admin } from '../index.js';
3
3
  import 'ampless';
4
4
  import '@ampless/runtime';
5
- import '../i18n-ByHM_Bho.js';
5
+ import '../i18n-DzXXcIQQ.js';
6
6
  import '@aws-amplify/adapter-nextjs';
7
7
 
8
8
  /**
@@ -0,0 +1,33 @@
1
+ 'use client';
2
+ import {
3
+ translate
4
+ } from "./chunk-OPQ3SAZJ.js";
5
+
6
+ // src/components/i18n-provider.tsx
7
+ import { createContext, useContext, useMemo } from "react";
8
+ import { jsx } from "react/jsx-runtime";
9
+ var I18nContext = createContext(null);
10
+ function I18nProvider({ locale, dict, children }) {
11
+ const value = useMemo(() => ({ locale, dict }), [locale, dict]);
12
+ return /* @__PURE__ */ jsx(I18nContext.Provider, { value, children });
13
+ }
14
+ function useT() {
15
+ const ctx = useContext(I18nContext);
16
+ if (!ctx) {
17
+ throw new Error(
18
+ "useT() called outside <I18nProvider>. Wrap the admin layout (or root layout) with <I18nProvider locale={...} dict={...}>."
19
+ );
20
+ }
21
+ return (key, vars) => translate(ctx.dict, key, vars);
22
+ }
23
+ function useLocale() {
24
+ const ctx = useContext(I18nContext);
25
+ if (!ctx) throw new Error("useLocale() called outside <I18nProvider>.");
26
+ return ctx.locale;
27
+ }
28
+
29
+ export {
30
+ I18nProvider,
31
+ useT,
32
+ useLocale
33
+ };
@@ -34,9 +34,12 @@ var en_default = {
34
34
  posts: "Posts",
35
35
  media: "Media",
36
36
  sites: "Sites",
37
+ users: "Users",
37
38
  viewSite: "View site",
38
39
  signOut: "Sign out",
39
- site: "Site"
40
+ site: "Site",
41
+ openMenu: "Open menu",
42
+ closeMenu: "Close menu"
40
43
  },
41
44
  dashboard: {
42
45
  title: "Dashboard",
@@ -76,6 +79,20 @@ var en_default = {
76
79
  tagsPlaceholder: "comma, separated, tags",
77
80
  tagsHint: "Used to group posts on tag pages (e.g. /tag/tech).",
78
81
  status: "Status",
82
+ noLayout: "No layout",
83
+ noLayoutHint: "Serve this post as bare HTML \u2014 no theme header, footer, or root layout. The body is returned as the entire response. Best paired with format: HTML when the body contains a full <!DOCTYPE html>\u2026</html> document.",
84
+ formatStaticLabel: "Static (zip / file bundle)",
85
+ static: {
86
+ pick: "Pick a .zip or one or more files",
87
+ pickHint: "Bundle assets must reference each other with relative paths only (no leading /). The zip's contents are extracted into a directory under your post slug and served verbatim \u2014 no theme chrome.",
88
+ currentBundle: "Current bundle: {count} files (entry: {entrypoint})",
89
+ pendingBundle: "Pending upload: {count} files, {size}",
90
+ issuesTitle: "{count} validation issue(s)",
91
+ issuesHint: "Fix the listed paths and re-upload. Absolute (/foo) and protocol-relative (//cdn.example/foo) references break under the bundle's URL prefix.",
92
+ emptyBundle: "No usable files found in the selection.",
93
+ noBundle: "Pick a bundle before saving.",
94
+ previewHint: "Static bundles render as the served HTML at /<slug>/. Preview by saving and visiting the public URL."
95
+ },
79
96
  saveChanges: "Save changes",
80
97
  createPost: "Create post",
81
98
  delete: "Delete",
@@ -147,6 +164,25 @@ var en_default = {
147
164
  label: "Site"
148
165
  }
149
166
  },
167
+ users: {
168
+ list: {
169
+ title: "Users",
170
+ description: "Promote signed-up users to admin or editor. Sign-ups always start with no role and must be granted access here.",
171
+ columnEmail: "Email",
172
+ columnRole: "Role",
173
+ columnActions: "Actions",
174
+ save: "Save",
175
+ saving: "Saving...",
176
+ saved: "Saved.",
177
+ cannotEditSelf: "You cannot change your own role.",
178
+ empty: "No users yet.",
179
+ loading: "Loading users...",
180
+ error: "Failed to load users",
181
+ roleAdmin: "Admin",
182
+ roleEditor: "Editor",
183
+ roleNone: "None"
184
+ }
185
+ },
150
186
  theme: {
151
187
  title: "Theme",
152
188
  activeLabel: "Active theme",
@@ -269,9 +305,12 @@ var ja_default = {
269
305
  posts: "\u8A18\u4E8B",
270
306
  media: "\u30E1\u30C7\u30A3\u30A2",
271
307
  sites: "\u30B5\u30A4\u30C8",
308
+ users: "\u30E6\u30FC\u30B6\u30FC",
272
309
  viewSite: "\u30B5\u30A4\u30C8\u3092\u8868\u793A",
273
310
  signOut: "\u30B5\u30A4\u30F3\u30A2\u30A6\u30C8",
274
- site: "\u30B5\u30A4\u30C8"
311
+ site: "\u30B5\u30A4\u30C8",
312
+ openMenu: "\u30E1\u30CB\u30E5\u30FC\u3092\u958B\u304F",
313
+ closeMenu: "\u30E1\u30CB\u30E5\u30FC\u3092\u9589\u3058\u308B"
275
314
  },
276
315
  dashboard: {
277
316
  title: "\u30C0\u30C3\u30B7\u30E5\u30DC\u30FC\u30C9",
@@ -311,6 +350,20 @@ var ja_default = {
311
350
  tagsPlaceholder: "\u30AB\u30F3\u30DE, \u533A\u5207\u308A, \u30BF\u30B0",
312
351
  tagsHint: "\u30BF\u30B0\u30DA\u30FC\u30B8\u3067\u8A18\u4E8B\u3092\u30B0\u30EB\u30FC\u30D4\u30F3\u30B0 (\u4F8B: /tag/tech)\u3002",
313
352
  status: "\u30B9\u30C6\u30FC\u30BF\u30B9",
353
+ noLayout: "\u30EC\u30A4\u30A2\u30A6\u30C8\u3092\u4F7F\u308F\u306A\u3044",
354
+ noLayoutHint: "\u30C6\u30FC\u30DE\u306E\u30D8\u30C3\u30C0\u30FC / \u30D5\u30C3\u30BF\u30FC / root layout \u3092\u4ECB\u3055\u305A\u3001\u672C\u6587\u3092 HTTP \u30EC\u30B9\u30DD\u30F3\u30B9\u672C\u4F53\u3068\u3057\u3066\u305D\u306E\u307E\u307E\u8FD4\u3057\u307E\u3059\u3002\u672C\u6587\u306B <!DOCTYPE html>\u2026</html> \u304C\u542B\u307E\u308C\u308B\u5834\u5408\u306F\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8: HTML \u3068\u306E\u7D44\u307F\u5408\u308F\u305B\u304C\u6700\u9069\u3067\u3059\u3002",
355
+ formatStaticLabel: "Static (zip / \u30D5\u30A1\u30A4\u30EB\u4E00\u62EC)",
356
+ static: {
357
+ pick: ".zip \u307E\u305F\u306F\u8907\u6570\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E",
358
+ pickHint: "\u30D0\u30F3\u30C9\u30EB\u5185\u306E\u30D5\u30A1\u30A4\u30EB\u9593\u53C2\u7167\u306F\u76F8\u5BFE\u30D1\u30B9\u306E\u307F (\u5148\u982D / \u306A\u3057)\u3002zip \u306E\u4E2D\u8EAB\u306F\u8A18\u4E8B slug \u306E\u914D\u4E0B\u306B\u5C55\u958B\u3055\u308C\u3001\u30C6\u30FC\u30DE\u88C5\u98FE\u3092\u4ECB\u3055\u305A\u305D\u306E\u307E\u307E\u914D\u4FE1\u3055\u308C\u307E\u3059\u3002",
359
+ currentBundle: "\u73FE\u5728\u306E\u30D0\u30F3\u30C9\u30EB: {count} \u30D5\u30A1\u30A4\u30EB (entry: {entrypoint})",
360
+ pendingBundle: "\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u5F85\u3061: {count} \u30D5\u30A1\u30A4\u30EB, {size}",
361
+ issuesTitle: "{count} \u4EF6\u306E\u691C\u8A3C\u30A8\u30E9\u30FC",
362
+ issuesHint: "\u8A72\u5F53\u30D1\u30B9\u3092\u4FEE\u6B63\u3057\u3066\u518D\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u7D76\u5BFE\u30D1\u30B9 (/foo) \u3084\u30D7\u30ED\u30C8\u30B3\u30EB\u7701\u7565 (//cdn.example/foo) \u306F\u30D0\u30F3\u30C9\u30EB\u306E URL prefix \u4E0B\u3067\u89E3\u6C7A\u3067\u304D\u307E\u305B\u3093\u3002",
363
+ emptyBundle: "\u9078\u629E\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u53D6\u308A\u51FA\u305B\u308B\u4E2D\u8EAB\u304C\u3042\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002",
364
+ noBundle: "\u4FDD\u5B58\u524D\u306B\u30D0\u30F3\u30C9\u30EB\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
365
+ previewHint: "Static \u30D0\u30F3\u30C9\u30EB\u306F /<slug>/ \u304B\u3089\u5B9F HTML \u3068\u3057\u3066\u914D\u4FE1\u3055\u308C\u307E\u3059\u3002\u4FDD\u5B58\u5F8C\u306B\u516C\u958B URL \u3092\u958B\u3044\u3066\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002"
366
+ },
314
367
  saveChanges: "\u5909\u66F4\u3092\u4FDD\u5B58",
315
368
  createPost: "\u8A18\u4E8B\u3092\u4F5C\u6210",
316
369
  delete: "\u524A\u9664",
@@ -382,6 +435,25 @@ var ja_default = {
382
435
  label: "\u30B5\u30A4\u30C8"
383
436
  }
384
437
  },
438
+ users: {
439
+ list: {
440
+ title: "\u30E6\u30FC\u30B6\u30FC",
441
+ description: "\u30B5\u30A4\u30F3\u30A2\u30C3\u30D7\u6E08\u307F\u30E6\u30FC\u30B6\u30FC\u3092\u7BA1\u7406\u8005\u307E\u305F\u306F\u7DE8\u96C6\u8005\u306B\u6607\u683C\u3057\u307E\u3059\u3002\u30B5\u30A4\u30F3\u30A2\u30C3\u30D7\u76F4\u5F8C\u306F\u30ED\u30FC\u30EB\u7121\u3057\u306E\u305F\u3081\u3001\u3053\u3053\u3067\u30A2\u30AF\u30BB\u30B9\u3092\u4ED8\u4E0E\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
442
+ columnEmail: "\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",
443
+ columnRole: "\u30ED\u30FC\u30EB",
444
+ columnActions: "\u64CD\u4F5C",
445
+ save: "\u4FDD\u5B58",
446
+ saving: "\u4FDD\u5B58\u4E2D...",
447
+ saved: "\u4FDD\u5B58\u3057\u307E\u3057\u305F\u3002",
448
+ cannotEditSelf: "\u81EA\u5206\u81EA\u8EAB\u306E\u30ED\u30FC\u30EB\u306F\u5909\u66F4\u3067\u304D\u307E\u305B\u3093\u3002",
449
+ empty: "\u30E6\u30FC\u30B6\u30FC\u304C\u3044\u307E\u305B\u3093\u3002",
450
+ loading: "\u30E6\u30FC\u30B6\u30FC\u3092\u8AAD\u307F\u8FBC\u307F\u4E2D...",
451
+ error: "\u30E6\u30FC\u30B6\u30FC\u4E00\u89A7\u306E\u53D6\u5F97\u306B\u5931\u6557\u3057\u307E\u3057\u305F",
452
+ roleAdmin: "\u7BA1\u7406\u8005",
453
+ roleEditor: "\u7DE8\u96C6\u8005",
454
+ roleNone: "\u306A\u3057"
455
+ }
456
+ },
385
457
  theme: {
386
458
  title: "\u30C6\u30FC\u30DE",
387
459
  activeLabel: "\u30A2\u30AF\u30C6\u30A3\u30D6\u30C6\u30FC\u30DE",
@@ -505,71 +577,8 @@ function translate(dict, key, vars) {
505
577
  });
506
578
  }
507
579
 
508
- // src/lib/media.ts
509
- var state = { outputs: null, cmsConfig: null };
510
- function setAdminMediaContext(outputs, cmsConfig2) {
511
- state.outputs = outputs;
512
- state.cmsConfig = cmsConfig2;
513
- }
514
- function publicMediaUrl(input) {
515
- if (/^https?:\/\//.test(input)) return input;
516
- let path = input.replace(/^\/+/, "");
517
- if (path.startsWith("public/")) path = path.slice("public/".length);
518
- const { outputs, cmsConfig: cmsConfig2 } = state;
519
- const delivery = cmsConfig2?.media?.delivery ?? "nextjs";
520
- if (delivery !== "s3-direct") return `/api/media/${path}`;
521
- const storage = outputs?.storage;
522
- if (!storage) return `/api/media/${path}`;
523
- return `https://${storage.bucket_name}.s3.${storage.aws_region}.amazonaws.com/public/${path}`;
524
- }
525
- function createMedia(outputs, cmsConfig2) {
526
- const storage = outputs.storage;
527
- function s3DirectUrl(path) {
528
- if (!storage) return `/api/media/${path}`;
529
- return `https://${storage.bucket_name}.s3.${storage.aws_region}.amazonaws.com/public/${path}`;
530
- }
531
- function urlFor(input) {
532
- if (/^https?:\/\//.test(input)) return input;
533
- let path = input.replace(/^\/+/, "");
534
- if (path.startsWith("public/")) path = path.slice("public/".length);
535
- const delivery = cmsConfig2.media?.delivery ?? "nextjs";
536
- return delivery === "s3-direct" ? s3DirectUrl(path) : `/api/media/${path}`;
537
- }
538
- return { publicMediaUrl: urlFor };
539
- }
540
-
541
- // src/lib/admin-site-client.ts
542
- import { DEFAULT_SITE_ID, isMultiSite } from "ampless";
543
- var ADMIN_SITE_COOKIE = "admin-site-id";
544
- var cmsConfig = null;
545
- function setAdminCmsConfig(config) {
546
- cmsConfig = config;
547
- }
548
- function readAdminSiteIdFromCookie() {
549
- if (!cmsConfig) return DEFAULT_SITE_ID;
550
- if (!isMultiSite(cmsConfig)) return DEFAULT_SITE_ID;
551
- const sites = cmsConfig.sites ?? {};
552
- if (typeof document !== "undefined") {
553
- const match = document.cookie.match(
554
- new RegExp(`(?:^|;\\s*)${ADMIN_SITE_COOKIE}=([^;]+)`)
555
- );
556
- if (match) {
557
- const v = decodeURIComponent(match[1]);
558
- if (sites[v]) return v;
559
- }
560
- }
561
- const first = Object.keys(sites)[0];
562
- return first ?? DEFAULT_SITE_ID;
563
- }
564
-
565
580
  export {
566
581
  resolveLocale,
567
582
  getDictionary,
568
- translate,
569
- setAdminMediaContext,
570
- publicMediaUrl,
571
- createMedia,
572
- ADMIN_SITE_COOKIE,
573
- setAdminCmsConfig,
574
- readAdminSiteIdFromCookie
583
+ translate
575
584
  };